package com.skycong.hello77.activity.common.viewbinder;

import android.widget.LinearLayout;


import com.skycong.hello77.activity.common.AuditStockDetailsProgressbarView;
import com.skycong.hello77.activity.common.EllipsizeTextView;
import com.skycong.hello77.activity.common.ImageListView;
import com.skycong.hello77.activity.common.ImgViewPager;
import com.skycong.hello77.activity.common.InputEditText;
import com.skycong.hello77.activity.common.LoadFrameLayout;
import com.skycong.hello77.activity.common.TfTextView;

import org.robobinding.binder.BinderFactory;
import org.robobinding.binder.BinderFactoryBuilder;
import org.robobinding.dynamicbinding.DynamicViewBinding;

public class ViewBinderUtil {

    private static volatile BinderFactory sReusableBinderFactory;

    public static synchronized BinderFactory getReusableBinderFactory() {
        if (sReusableBinderFactory == null) {
            sReusableBinderFactory = createBinderFactory();
        }
        return sReusableBinderFactory;
    }

    private static BinderFactory createBinderFactory() {
        BinderFactory binderFactoryBuilder = new BinderFactoryBuilder()
                .add(new DynamicViewBinding().forView(InputEditText.class).oneWayProperties("transferMethod", "validateListener"))
                .add(new DynamicViewBinding().forView(LoadFrameLayout.class).oneWayProperties("listener", "number", "states"))
                .add(new DynamicViewBinding().forView(TfTextView.class).oneWayProperties("drawableTop", "drawableLeft", "drawableRight", "textColorHint", "viewBackgroundColor","backgroundResId","textColor", "boldText"))
                .add(new DynamicViewBinding().forView(ImgViewPager.class).oneWayProperties("imgList"))
                .add(new DynamicViewBinding().forView(AuditStockDetailsProgressbarView.class).oneWayProperties("dataSource"))
                .add(new DynamicViewBinding().forView(ImageViewInfo.class).oneWayProperties("src"))
                .add(new DynamicViewBinding().forView(EllipsizeTextView.class).oneWayProperties("ellipsizeIndex", "drawableRight"))
                .add(new DynamicViewBinding().forView(LinearLayout.class).oneWayProperties("background"))
                .add(new DynamicViewBinding().forView(ImageListView.class).oneWayProperties("data", "modelStyle", "onItemListener"))
                .build();
        return binderFactoryBuilder;
    }
}
